#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File         :filter.py
@Description  :
@Time         :2024/05/21 09:37:07
@Author       :Lin Yuheng
@Version      :1.0
'''

class Filter:
    def __init__(self, filter_param=0.1):
        """
        @Description : 一阶低通滤波器
        @Param:
        @Returns     :
        """

        self.filter_param = filter_param # alpha = dt / (tau + dt) tau:时间常数； dt 采样时间间隔
        self.prev_output = 0.0

    def update(self, input):
        output = self.filter_param * input + (1 - self.filter_param) * self.prev_output
        self.prev_output = output
        return output

        